<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link rel="stylesheet" th:href="@{/css/main.css}" />
    <link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet"  crossorigin="anonymous">
    <title>SpringMVC5+Thymeleaf示例</title>
    <script>

            function checkOnlyByName()
        {
            var xmlhttp;
            if (window.XMLHttpRequest)
            {// code for IE7+, Firefox, Chrome, Opera, Safari
                xmlhttp=new XMLHttpRequest();
            }
            else
            {// code for IE6, IE5
                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            xmlhttp.onreadystatechange=function()
            {
                if (xmlhttp.readyState==4 && xmlhttp.status==200)
                {
                    document.getElementById("checkName").innerHTML=xmlhttp.responseText;
                    document.getElementById("checkName").focus();
                }
            }
            var str=document.getElementById("name").value;
            xmlhttp.open("GET","/Student/checkOnlyByName?name="+str,true);
            xmlhttp.send();
        }

        function checkOnlyById() {
            var xmlhttp;
            if (window.XMLHttpRequest)
            {// code for IE7+, Firefox, Chrome, Opera, Safari
                xmlhttp=new XMLHttpRequest();
            }
            else
            {// code for IE6, IE5
                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            xmlhttp.onreadystatechange=function()
            {
                if (xmlhttp.readyState==4 && xmlhttp.status==200)
                {
                    document.getElementById("checkId").innerHTML=xmlhttp.responseText;
                    document.getElementById("checkId").focus();
                }
            }
            var str=document.getElementById("id").value;
            xmlhttp.open("GET","/Student/checkOnlyById?id="+str,true);
            xmlhttp.send();
        }
    </script>
</head>
<body><form action="/Student/add.do" method="post" class="form-control">

    id:<input type="text" id="id" name="id" onblur="checkOnlyById(this)"><br>
    <div id="checkId">输入学号</div>    <br>

    name:<input type="text" id="name" name="name" onblur="checkOnlyByName(this)">
    <div id="checkName">请注意用户名，以字母开头</h2></div>    <br>

    password:<input type="password" name="password"><br>
    sex:<input type="text" name="sex"><br>
    class:<input type="text" name="clazz"><br>
    birthday:<input type="text" name="birthday"><br>
    <input type="submit" value="add student">
</form>
<script src="/bootstrap/js/bootstrap.bundle.min.js"  crossorigin="anonymous"></script>
</body>
</html>